package org.labuladong.动态规划算法.DP;

import java.util.Arrays;

/**
 * @Auther: qingle
 * @Date: 2024/10/23-9:35
 * @Description: 带备忘录的迭代解法
 * @version: 1.0
 */
public class dp01_Fibonaci_dp {

	public static int fib(int N) {
		// 边界条件
		if (N <= 1) return N;

		// 备忘录
		int[] memoDp = new int[N + 1];
		Arrays.fill(memoDp, 0);

		memoDp[1] = 1;
		memoDp[2] = 1;
		for (int i = 3; i < N + 1; i++) {
			// 状态转移方程
			memoDp[i] = memoDp[i - 1] + memoDp[i - 2];
		}
		return memoDp[N];
	}


	public static void main(String[] args) {

		System.out.println(fib(10));

	}
}
